treeview: Handle the case where the cursor row gets deleted
authorBenjamin Otte <otte@redhat.com>
Sat, 10 Dec 2011 03:48:12 +0000 (04:48 +0100)
committerBenjamin Otte <otte@redhat.com>
Sat, 10 Dec 2011 07:00:26 +0000 (08:00 +0100)
commit1a2932ba2915c34171581a85afba39311e9c3ac6
tree1dcc81f67e4b4f94ed2bb3231ec4e96b88700c57
parente01af5c5c97517ce6d85147bb07460db48ec997c
treeview: Handle the case where the cursor row gets deleted

Previously, the cursor would just become invalid, which used to
reselect the first row in the treeview later on (without a
cursor-changed signal). This leads to a crash now with the recent
refactorings.

The patch is longer than I'd like it to be, but the situation is kinda
complicated, because we want to make sure to move the cursor to a good
row. It works like this:
1) From the deleted row, search forward for the first row that is not
   going to be deleted and is not a separator.
2) If no such row exists, search backwards for a row that is not a
   separator.
3) If no such node exists, clear the cursor.
gtk/gtktreeview.c